<template>
  <div class="dashboard-container">

    <el-row     :loading="loading" style="padding: 20px" :gutter="20">
      <el-col :span="6">
        <div class="grid-content bg-purple">

          <svg-icon
            class="iconclass"
            icon-class="student"
          ></svg-icon>
          <div>

            <span class="tips">用户数量：</span>
            <span class="nums">{{ usercount }}</span>
          </div>
        </div>
      </el-col>
      <el-col :span="6">
        <div class="grid-content bg-purple">
          <svg-icon
            class="iconclass"
            icon-class="teacher"
          ></svg-icon>
          <div>
            <span class="tips">医生数量：</span>
            <span class="nums">{{ doctorcount }}</span>
          </div>

        </div>
      </el-col>
      <el-col :span="6">
        <div class="grid-content bg-purple">
          <svg-icon
            class="iconclass"
            icon-class="classroom"
          ></svg-icon>
          <div>
            <span class="tips">现有患者数量：</span>
            <span class="nums">{{ nowpatient }}</span>
          </div>

        </div>
      </el-col>
      <el-col :span="6">
        <div class="grid-content bg-purple">
          <svg-icon
            class="iconclass"
            icon-class="paper"
          ></svg-icon>
          <div>
            <span class="tips">确诊人数：</span>
            <span class="nums">{{ allpatient }}</span>
          </div>

        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import { getDashboardInfo } from '@/api/admin'

export default {
  name: 'dashboard',
  data() {
    return {

      usercount: 0,
      doctorcount: 0,
      nowpatient: 0,
      allpatient: 0,
      loading:false,
    }
  },
  mounted() {
    this.getbaseinfo()
  },
  methods: {
    getbaseinfo() {
      this.loading = true;
      getDashboardInfo().then(res=>{
        console.log(res)
        this.usercount = res.usercount;
        this.doctorcount = res.doctorcount;
        var spiderinfo = res.spiderinfo.data;
        var spiderobj = JSON.parse(spiderinfo);

        spiderobj.getAreaStat.forEach(ele=>{
          this.nowpatient += ele.currentConfirmedCount;
          this.allpatient += ele.confirmedCount;
        })
        this.loading = false;
        console.log(spiderobj);
        // this.nowpatient = res.papercount;
        // this.classroomcount = res.classroomcount;
      }).catch(err=>{
        console.log(err)
      })
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.iconclass {
  font-size: 60px;
}

.tips {
  font-size: 20px;
}

.nums {
  font-size: 50px;
}

.el-row {
  margin-bottom: 20px;

  &:last-child {
    margin-bottom: 0;
  }
}

.el-col {
  border-radius: 4px;
}

.bg-purple-dark {
  background: #99a9bf;
  color: #1482f0;
}

.bg-purple {
  background: #d3dce6;
  color: #1a90ac;
}

.bg-purple-light {
  background: #e5e9f2;
  color: #4ed038;
}

.grid-content {
  border-radius: 4px;
  padding: 10px;
  min-height: 36px;
}

.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}
</style>
